package com.cloud.phone.view;


import android.os.Handler;
import android.os.Looper;
import android.provider.Settings;

import com.blankj.utilcode.util.ToastUtils;
import com.cloud.phone.base.BaseApp;

public class TsUtils {
    private static FloatTips floatTips;
    public static void showTips(String msg){
        if(Looper.myLooper()==Looper.getMainLooper()) {
            if (floatTips == null) {
                floatTips = new FloatTips(BaseApp.app.getApplicationContext());
                floatTips.setGravity(FloatTips.BOTTOM);
                floatTips.setDuration(FloatTips.LENGTH_ALWAYS);
            }
            floatTips.setText(msg);
            if (!Settings.canDrawOverlays(BaseApp.app)) {
                ToastUtils.showShort(msg);
            }else{
                floatTips.show();
            }
        }else{
            new Handler(Looper.getMainLooper()).post(new Runnable() {
                @Override
                public void run() {
                    if (floatTips == null) {
                        floatTips = new FloatTips(BaseApp.app.getApplicationContext());
                        floatTips.setGravity(FloatTips.BOTTOM);
                        floatTips.setDuration(FloatTips.LENGTH_ALWAYS);
                    }
                    floatTips.setText(msg);
                    if (!Settings.canDrawOverlays(BaseApp.app)) {
                        ToastUtils.showShort(msg);
                    }else{
                        floatTips.show();
                    }
                }
            });
        }
    }
}


